package Demo1;

import java.util.concurrent.Callable;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-03-15
 * Time: 21:26
 */
public class Test {
    public static void func2(Animal animal){
        System.out.println("父类接收了");
    }
    public static Animal func1(){
        Dog dog = new Dog("旺财" , 3);
        return dog;
    }
    public static void main(String[] args) {
       Dog dog = new Dog("小黑", 2);
        // System.out.println("========================");
        //Cat cat = new Cat("小白" , 3);
        //System.out.println(dog);
       // dog.eat();
        //cat.eat();
        //向上转型(不能调用子类特有的方法)
        Animal animal = new Dog("小黑", 2);
        System.out.println(animal);
        System.out.println(animal.a);
        System.out.println(dog.a);
        Animal animal2 = func1();//也会发生向上转型
        System.out.println(animal2.a);
        func2(dog);
    }
}
